package cn.stylefeng.guns.czlm.service;

import cn.stylefeng.guns.core.common.page.LayuiPageFactory;
import cn.stylefeng.guns.czlm.entity.TbCoupon;
import cn.stylefeng.guns.czlm.mapper.TbCouponMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

@Service
public class TbCouponService extends ServiceImpl<TbCouponMapper, TbCoupon> {
    @Resource
    private TbCouponMapper couponMapper;

    //分页查询所有
    public Page<Map<String, Object>> selectCoupons(String name,Integer active){
        Page page = LayuiPageFactory.defaultPage();
        Page<Map<String, Object>> list=this.couponMapper.selectCoupons(page,name,active);
        return this.couponMapper.selectCoupons(page,name,active);
    }

    //删除滑块
    public void UpdateActive(Integer id,int active){
        TbCoupon cou=new TbCoupon();
        cou.setId(id);
        cou.setActive(active);
        couponMapper.updateById(cou);
    }

    //添加
    public void insertTbCoupon(TbCoupon coupon){
        couponMapper.insertTbCoupon(coupon);
    }

    //按id查询[回显]
    public TbCoupon selectById(Integer id){
        return couponMapper.selectById(id);
    }


}
